#-------------------------------------------------------------------------------
#   Compiler
#-------------------------------------------------------------------------------
cc=g++
cco=$(cc) $(CFLAGS) $(GENERAL_INCLUDES) -o $@
#-------------------------------------------------------------------------------
#   Compiler
#-------------------------------------------------------------------------------
AR=/usr/bin/ar $@ $?

#-------------------------------------------------------------------------------
#   Flags
#-------------------------------------------------------------------------------
DEBUG= -g
CFLAGS = -Wall -c $(DEBUG) -std=c++0x
LFLAGS = -Wall $(DEBUG) -std=c++0x

#-------------------------------------------------------------------------------
#   Directories
#-------------------------------------------------------------------------------
PROJECT_DIR=$(SRC)/
EXE_DIR=$(EXE)/
OBJ_DIR=$(OBJ)/
COMMON_DIR=$(PROJECT_DIR)common/
DHASH_DIR=$(PROJECT_DIR)directoHash/
DHASH_KEYS_DIR=$(DHASH_DIR)keys/
DHASH_RECORDS_DIR=$(DHASH_DIR)records/
TEST_DIR=$(PROJECT_DIR)test/

#-------------------------------------------------------------------------------
#   Includes
#-------------------------------------------------------------------------------
INCLUDE_COMMON=-I $(COMMON_DIR)
INCLUDE_DHASH=-I $(DHASH_DIR) -I $(DHASH_KEYS_DIR) -I $(DHASH_RECORDS_DIR)
INCLUDE_TEST=-I $(TEST_DIR)

USR_INCLUDE=/usr/include
GCC_INCLUDE=/usr/lib/gcc
LOCAL_INCLUDE=/usr/local/include


GENERAL_INCLUDES=-I $(USR_INCLUDE) -I $(GCC_INCLUDE) -I $(LOCAL_INCLUDE) $(INCLUDE_TEST) \
				$(INCLUDE_COMMON) $(INCLUDE_DHASH)

#-------------------------------------------------------------------------------
lib_tgt=$(EXE_DIR)lib_common.a

lib_obj=$(OBJ_DIR)arbolbmas.o \
	$(OBJ_DIR)container.o \
	$(OBJ_DIR)iteradorbmas.o \
	$(OBJ_DIR)nodo.o \
	$(OBJ_DIR)CargadorMasivo.o \
	$(OBJ_DIR)QueryEjecutor.o \
	$(OBJ_DIR)mapeador.o

#-------------------------------------------------------------------------------
#   Todo
#-------------------------------------------------------------------------------

all: 	lib_common
	@echo 'Objetos common -> Actualizado!'

init:
	@$S
	
lib_common : init $(lib_tgt)
	@$S
	
$(lib_tgt) : $(lib_obj)
#	$(AR)

#-------------------------------------------------------------------------------
#   Objetos
#-------------------------------------------------------------------------------

$(OBJ_DIR)arbolbmas.o: $(COMMON_DIR)arbolbmas.cpp
	@$S
	$(cco) $(COMMON_DIR)arbolbmas.cpp 

$(OBJ_DIR)container.o: $(COMMON_DIR)container.cpp
	@$S
	$(cco) $(COMMON_DIR)container.cpp 

$(OBJ_DIR)iteradorbmas.o: $(COMMON_DIR)iteradorbmas.cpp
	@$S
	$(cco) $(COMMON_DIR)iteradorbmas.cpp 

$(OBJ_DIR)nodo.o: $(COMMON_DIR)nodo.cpp
	@$S
	$(cco) $(COMMON_DIR)nodo.cpp 

$(OBJ_DIR)CargadorMasivo.o: $(COMMON_DIR)CargadorMasivo.cpp
	@$S
	$(cco) $(COMMON_DIR)CargadorMasivo.cpp

$(OBJ_DIR)QueryEjecutor.o: $(COMMON_DIR)QueryEjecutor.cpp
	@$S
	$(cco) $(COMMON_DIR)QueryEjecutor.cpp

$(OBJ_DIR)mapeador.o: $(COMMON_DIR)mapeador.cpp
	@$S
	$(cco) $(COMMON_DIR)mapeador.cpp
	
#-------------------------------------------------------------------------------
clean :
	@$S
	rm -rf $(lib_obj)
	@echo 'Cleaned obj common !'

#-------------------------------------------------------------------------------